﻿using System.Collections.Generic;
using Kam.Lagan.Examples.Atm.Contract.Model;

namespace Kam.Lagan.Examples.Atm.Model
{
    public class CurrentAccount : ICurrentAccount
    {
        private readonly List<ITransaction> _transactions; 

        public CurrentAccount(IClient client, string number, string sortCode, string iban)
        {
            Client = client;
            Number = number;
            SortCode = sortCode;
            Iban = iban;
            _transactions = new List<ITransaction>();
        }

        public IClient Client { get; private set; }

        public string Number { get; private set; }

        public string SortCode { get; private set; }

        public string Iban { get; private set; }

        public IEnumerable<ITransaction> Transactions { get { return _transactions.AsReadOnly(); } }

        public void Transact(ITransaction transaction)
        {
            if (transaction != null)
            {
                _transactions.Add(transaction);
            }
        }
    }
}
